-
Notifications
You must be signed in to change notification settings - Fork 203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix duplication of homonyms #2746
Fix duplication of homonyms #2746
Conversation
Fixes: Two items that would resolve to the same path after name conflict resolution actually end up being duplicated into the same name. So duplicating "bob1" and "bob2" in the same selection would result in a single "bob3" and a missing "bob4". The code now creates and executes sub-duplication tasks in the main loop to make sure the name conflict resolution sees the complete picture.
for (auto&& item : selection) { | ||
if (UsdSceneItem::Ptr usdItem = std::dynamic_pointer_cast<UsdSceneItem>(item)) { | ||
// Currently unordered_map since we need to streamline the targetItem override. | ||
_perItemCommands[item->path()] = UsdUndoDuplicateCommand::create(usdItem); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't pre-create all the tasks because the name conflict resolution code will not incrementally see the new paths.
Pre-flight passed. Only one random test failure on the usual |
UsdSceneItem::Ptr usdItem = std::dynamic_pointer_cast<UsdSceneItem>(item); | ||
if (usdItem) { | ||
canDuplicate = true; | ||
break; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Comment] Would it be interesting to continue the loop to remove null usdItem
from the list?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.. allowing to remove lines 88 to 90 & perhaps right away create a list/set of UsdSceneItem::Ptr
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe. Anyway this will be revisited at some point to fix MAYA-125854 and we will also remove all usdItems that have a parent in the list.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, that was a great idea and it also provided a very efficient way to fix MAYA-125854. Done.
As inspired by a review comment.
test/lib/ufe/testDuplicateCmd.py
Outdated
batchOpsHandler = ufe.RunTimeMgr.instance().batchOpsHandler(geomItem.runTimeId()) | ||
self.assertIsNotNone(batchOpsHandler) | ||
|
||
# Put then in a selection, making sure one child item is first, and that another child item is last. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Nit] Typo: "then" -> "them"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
9a2ea3b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Fixes: Two items that would resolve to the same path after name conflict resolution actually end up being duplicated into the same name.
So duplicating "bob1" and "bob2" in the same selection would result in a single "bob3" and a missing "bob4".
The code now creates and executes sub-duplication tasks in the main loop to make sure the name conflict resolution sees the complete picture.